package mse.eai.jbpm.lotteryResultsProcess;

import java.util.HashMap;

import org.jboss.logging.Logger;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

public class PrepareESBVarsGetWinersList implements ActionHandler {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8082313114736763310L;
	private static final Logger log = Logger
			.getLogger(PrepareESBVarsGetWinersList.class);

	public void execute(ExecutionContext context) throws Exception {

		log.info("Executing ---------->");

		try {

			// Cria o map para enviar ao ESB
			HashMap requestMap = new HashMap();

			// getWinersList (sourceAppId)
			requestMap.put("arg0", 1);

			context.setVariable("toESB", requestMap);
			
			log.info("Set in context: " + "toESB  = " + requestMap);

			context.leaveNode();

		} catch (Exception ex) {
			log.error("Exception: ", ex);
			log.error("ProcessInstance will be suspended");
			context.getProcessInstance().suspend();
		}
		log.info("<--------------- Done");

	}

}